#ifndef CCARD_H
#define CCARD_H

#include <ostream>

using namespace std;

/*****************************************************************************/
/**                                 class CCard                             **/
/*****************************************************************************/

class CCard
{
public:
    typedef enum:char {sHearts, sDiamonds, sClubs, sSpades} SuitType;
    typedef enum:char {vTwo = 2, vThree, vFour, vFive, vSix, vSeven, vEight, vNine, vTen, vJack, vQueen, vKing, vAce} ValueType;

    CCard(SuitType s, ValueType v)
    {
        mSuit = s;
        mValue = v;
    };

    CCard(const string& shortcut);

    bool operator == (const CCard& card) const
    {
        return ( (card.mSuit == mSuit) && (card.mValue == mValue));
    }

    SuitType getSuit()   const { return mSuit; }
    ValueType getValue() const { return mValue; }

private:
    SuitType mSuit;
    ValueType mValue;

    friend bool cmpByValue(const CCard&, const CCard&);
    friend bool cmpBySuit(const CCard&, const CCard&);
    friend bool operator < (const CCard& rhs, const CCard& lhs);
};

ostream& operator << (ostream& ostr, const CCard& card);

inline bool operator < (const CCard& rhs, const CCard& lhs)
{
    if (lhs.mSuit == rhs.mSuit)
        return (lhs.mValue < rhs.mValue);
    return (lhs.mSuit < rhs.mSuit);
}

inline bool cmpByValue(const CCard& lhs, const CCard& rhs)
{
    return (lhs.mValue > rhs.mValue);
}

inline bool cmpBySuit(const CCard& lhs, const CCard& rhs)
{
    return (lhs.mSuit > rhs.mSuit) && cmpByValue(lhs, rhs);
}

char CardValueToChar(CCard::ValueType cardValue);

#endif // CCARD_H
